define(['knockout', 'util', 'knockout-mapping'], function (ko, Util) {
    function ViewModel(params) {
        $.extend(this, {
            logo: '',
            title: ''
        })
        Util.extend(this, params);

        var scope = this;

        scope.css = {'xgx-login-desktop': !ko.root.mobile, 'xgx-login-mobile': ko.root.mobile};
        $.extend(scope.css, {'container-fluid': true});
        scope.loginForm = {
            onLogin: function (formData, callback) {
                Util.ajaxPost({url:scope.url, data:ko.mapping.toJSON(formData), callback:function (data) {
                    if (data.success) {
                        //we need change password when first login
                        if (data.data && data.data.logged != undefined && data.data.logged == 0) {
                            callback();
                        }
                        else {
                            if (scope.onLoginSuccess) {
                                scope.onLoginSuccess(data);
                            }
                        }
                    }
                }});
            },
            onModifyPassword: function () {

            }
        }
    }

    return ViewModel;
});
